package com.example.spring.demo.configuration;
/**
 * 邢帅教育
 * <p>
 * 本源代码由数据中心及其作者共同所有，未经版权持有者的事先书面授权，
 * 不得使用、复制、修改、合并、发布、分发和/或销售本源代码的副本。
 *
 * @copyright Copyright (c) 2018. xsteach.com all rights reserved.
 */

import com.example.spring.demo.interceptor.DemoHandlerInterceptor;
import com.example.spring.demo.interceptor.SecondHandlerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author maikec
 * @date 2018/9/17
 */
@Configuration
public class DemoWebMvc extends WebMvcConfigurationSupport {
    @Override
    public void addInterceptors (InterceptorRegistry registry) {
        registry.addInterceptor( handlerInterceptor() );
        registry.addInterceptor( secondHandlerInterceptor() );
    }
    @Bean
    public HandlerInterceptor handlerInterceptor() {
        return new DemoHandlerInterceptor();
    }

    @Bean
    public HandlerInterceptor secondHandlerInterceptor() {
        return new SecondHandlerInterceptor();
    }
}
